a11y: Get the accessible role once
authorEmmanuele Bassi <ebassi@gnome.org>
Thu, 19 Nov 2020 14:27:30 +0000 (14:27 +0000)
committerEmmanuele Bassi <ebassi@gnome.org>
Thu, 19 Nov 2020 15:20:56 +0000 (15:20 +0000)
Simplify getting the accessible role when checking if an accessible
implementation should present itself; this avoids going through
GtkAccessible twice to get the same data.

gtk/gtkaccessible.c

index 991bc02756c91dea9abd29b5885fafffd1aba490..ed89fa97148c9a5d74b129a91acd16a02092e11f 100644 (file)
@@ -756,14 +756,16 @@ gtk_accessible_bounds_changed (GtkAccessible *self)
 gboolean
 gtk_accessible_should_present (GtkAccessible *self)
 {
+  GtkAccessibleRole role;
   GtkATContext *context;
 
   if (GTK_IS_WIDGET (self) &&
       !gtk_widget_get_visible (GTK_WIDGET (self)))
     return FALSE;
 
-  if (gtk_accessible_get_accessible_role (self) == GTK_ACCESSIBLE_ROLE_NONE ||
-      gtk_accessible_get_accessible_role (self) == GTK_ACCESSIBLE_ROLE_PRESENTATION)
+  role = gtk_accessible_get_accessible_role (self);
+  if (role == GTK_ACCESSIBLE_ROLE_NONE ||
+      role == GTK_ACCESSIBLE_ROLE_PRESENTATION)
     return FALSE;
 
   context = gtk_accessible_get_at_context (self);